<?php
	$groupid = checkUserGroup($_SESSION['username']);
	$members = getMembers($groupid);
	$totalmembers = getNumUsers($groupid);
	$membercount = 0;
	
	echo "<p>Please distribute the bill total of $" . $_POST['billTotal'] . " amongst the group members listed below.<br />
		You may select a value from 0 to the bill total.</p>";
	
	echo "<form name=\"billDistro\" id=\"billDistro\" method=\"post\" action=\"?addbill&billtype&share&complete\" onSubmit=\"javascript:return checkDistroTotals(" . $totalmembers . ", " . $_POST['billTotal'] . ");\">";
	echo "<table>
			<tr>
				<td><p><strong>Member</strong></p></td>
				<td><p><strong>Share</strong></p></td>
			</tr>";
	while ($row = mysql_fetch_array($members)) {
		$membercount = $membercount + 1;
		echo "<tr>
				<td><p>" . $row[1] . " " . $row[2] . "</p></td>
				<td><input type=\"text\" name=\"member" . $membercount . "\" id=\"member" . $membercount . "\" maxlength=\"7\" size=\"7\" /></td>
			</tr>";
	}
	echo "</table>";
	echo '<input type="hidden" name="members" value="' . $totalmembers . '">';
	echo '<input type="hidden" name="billTotal" value="' . $_POST['billTotal'] . '">';
	echo '<input type="hidden" name="billName" value="' . $_POST['billName'] . '">';
	echo '<input type="hidden" name="billType" value="' . $_POST['billType'] . '">';
	echo '<input type="hidden" name="dueDate" value="' . $_POST['dueDate'] . '">';
	echo "<input type=\"submit\" value=\"Continue\">";
	echo "</form>";
?>